// FunctionFactory.cpp: implementation of the FunctionFactory class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "FunctionFactory.h"
#include "ProductCatalog.h"
#include "DBConnectionManager.h"
#include "ProductCatalogManager.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

using namespace DAWrapper;

FunctionFactory::FunctionFactory()
{

}

FunctionFactory::~FunctionFactory()
{
	
}

FunctionStack& FunctionFactory::GetFunctionStack(const CString& strID,
												 const CString& strStandard)
{
	ASSERT(!strID.IsEmpty());
	ASSERT(!strStandard.IsEmpty());

	FunctionStack* pStack = NULL;

	CString strKey = strID + strStandard;
	pStack = FindFunctionStack(strKey);
	if(pStack != NULL)
	{
		return *pStack;
	}

	ASSERT(FALSE);
	return *pStack;
}

FunctionStack* FunctionFactory::NewFunctionStack(const CString& strID,
												 const CString& strStandard)
{
	CString strDataSource;
	JointSystem::ProductCatalog* pCatalog = NULL;
	pCatalog = JointSystem::ProductCatalogManager::Instance()->GetProductCatalog(strStandard);
	ASSERT(pCatalog);
	strDataSource = pCatalog->DataSourceURI();
	ASSERT(!strDataSource.IsEmpty());

	_ConnectionPtr* pCon = DBConnectionManager::Instance()->GetConnectionPtrByUri(strDataSource);
	ASSERT(FALSE);
	return NULL;
}

FunctionStack* FunctionFactory::FindFunctionStack(const CString& strKey)
{
	FunctionStack* pStack = NULL;
	
	m_theFunctionTemplate.Lookup(strKey, pStack);
	
	return pStack;
}
